home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 12 / BBS in a box XII-2.iso / Files II / Prog / B-C / C++ CDEV.sit / C++ CDEV ƒ / UControlPanel.cp / UControlPanel.cp
Encoding:
Text File  |  1991-08-24  |  1.4 KB  |  62 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    UControlPanel.cp (MPW 3.2)
  3.  *    Copyright ©1991 David Kreindler.  All rights reserved.
  4.  *    
  5.  *    KNOWN BUGS AND SHORTCOMINGS:
  6.  *        TControlPanel::DoKeyEvent() contains hard-coded menu key equivalents; they should be stored as resources
  7.  */
  8.  
  9. #ifndef __UCONTROLPANEL__
  10. #include <UControlPanel.h>
  11. #endif
  12.  
  13. void TControlPanel::DoCursor(long *) {
  14.     Point cursLoc;
  15.     GetMouse(&cursLoc);
  16.     short dialogItem;
  17.     if (dialogItem = this->FindDItem(cursLoc)) {
  18.         Handle item;
  19.         Rect itemRect;
  20.         short itemType;
  21.         this->GetDItem(dialogItem, &itemType, &item, &itemRect);
  22.         switch (itemType) {
  23.             case editText:
  24.             case editText + itemDisable:
  25.                 SetCursor(iBeamCursor);
  26.                 break;
  27.             default:
  28.                 SetCursor(crossCursor);
  29.         }
  30.     }
  31.     else
  32.         SetCursor(crossCursor);
  33. }
  34.  
  35. void TControlPanel::DoKeyEvent(EventRecord *theEvent, long *cdevValue) {
  36.     enum {                                                                                    // !!!
  37.         kCopy = 'c', kCopy_U = 'C',
  38.         kCut = 'x', kCut_U = 'X',
  39.         kPaste = 'v', kPaste_U = 'V',
  40.         kUndo = 'z', kUndo_U = 'Z'
  41.     };
  42.     if (theEvent->modifiers & cmdKey) {                                                        // check for a keyboard menu command
  43.         switch (theEvent->message & charCodeMask) {                                            // isolate the character code
  44.             case kCopy:
  45.             case kCopy_U:
  46.                 DoCopy(cdevValue);
  47.                 break;
  48.             case kPaste:
  49.             case kPaste_U:
  50.                 DoPaste(cdevValue);
  51.                 break;
  52.             case kCut:
  53.             case kCut_U:
  54.                 DoCut(cdevValue);
  55.                 break;
  56.             case kUndo:
  57.             case kUndo_U:
  58.                 DoUndo(cdevValue);
  59.         }
  60.         theEvent->what = nullEvent;                                                            // skip the Dialog Manager
  61.     }
  62. }